Imports CapaDeDatos
Public Class nChequera
    Public Chequera As CapaDeDatos.dChequera = New CapaDeDatos.dChequera
    Public Cuentas As CapaDeDatos.dCuenta = New CapaDeDatos.dCuenta
    Public Banco As CapaDeDatos.dBanco = New CapaDeDatos.dBanco
    Public Function InsertarChequera(ByVal Comienzo As Integer, ByVal Ultimo As Integer, ByVal CodigoCuenta As Integer) As Boolean
        Return Chequera.Insertar(Comienzo, Ultimo, CodigoCuenta)
    End Function
    Public Function ExisteChequera(ByVal Comienzo As Integer, ByVal Ultimo As Integer, ByVal CodigoCuenta As Integer) As Boolean
        Return Chequera.BuscarFiltrado(0, Comienzo, Ultimo, CodigoCuenta).Tables(0).Rows.Count <> 0
    End Function
    Public Function EliminarChequera(ByVal CodigoChequera As Integer) As Boolean
        Return Chequera.Eliminar(CodigoChequera)
    End Function
    Public Function ModificarChequera(ByVal CodigoChequera As Integer, ByVal Comienzo As Integer, ByVal Ultimo As Integer, ByVal CodigoCuenta As Integer) As Boolean
        Return Chequera.Modificar(CodigoChequera, comienzo, Ultimo, codigoCuenta)
    End Function
    Public Function ListarChequeras(ByVal CodigoChequera As Integer, ByVal Comienzo As Integer, ByVal Ultimo As Integer, ByVal CodigoCuenta As Integer) As DataSet
        Dim dtsChequera As DataSet
        dtsChequera = Chequera.BuscarFiltrado(CodigoChequera, Comienzo, Ultimo, CodigoCuenta)
        dtsChequera.Tables(0).Columns.Add("Rango")
        Dim i As Integer
        For i = 0 To dtsChequera.Tables(0).Rows.Count - 1
            Try
                dtsChequera.Tables(0).Rows(i)("Rango") = dtsChequera.Tables(0).Rows(i)("Comienzo").ToString() + " - " + dtsChequera.Tables(0).Rows(i)("Ultimo").ToString()
            Catch ex As Exception
                dtsChequera.Tables(0).Rows(i)("Rango") = "ERROR!"
            End Try
        Next
        Return dtsChequera
    End Function
    Public Function ListarTodos(ByVal CodigoChequera As Integer, ByVal Comienzo As Integer, ByVal Ultimo As Integer, ByVal CodigoCuenta As Integer) As DataSet
        Dim dtsPrincipal As DataSet
        dtsPrincipal = Chequera.BuscarFiltrado(CodigoChequera, Comienzo, Ultimo, CodigoCuenta)
        dtsPrincipal.Tables(0).Columns.Add("Denominacion")
        dtsPrincipal.Tables(0).Columns.Add("NumeroCuenta")
        Dim i As Integer
        For i = 0 To dtsPrincipal.Tables(0).Rows.Count - 1
            Try
                dtsPrincipal.Tables(0).Rows(i)("Denominacion") = Banco.BuscarFiltradoNom(Cuentas.DarBanco(Int(dtsPrincipal.Tables(0).Rows(i)("CodigoCuenta").ToString()), 0), "").Tables(0).Rows(0)("Denominacion").ToString()
            Catch ex As Exception
                dtsPrincipal.Tables(0).Rows(i)("Denominacion") = "Error, Banco no Encontrado"
            End Try
            Try
                dtsPrincipal.Tables(0).Rows(i)("NumeroCuenta") = Cuentas.BuscarFiltrado(Int(dtsPrincipal.Tables(0).Rows(i)("CodigoCuenta").ToString()), "", "", 0, "").Tables(0).Rows(0)("NumeroCuenta").ToString()
            Catch ex As Exception
                dtsPrincipal.Tables(0).Rows(i)("NumeroCuenta") = "Error, Cuenta no Encontrada"
            End Try
        Next
        Return dtsPrincipal
    End Function
End Class
